package timbap.visualizer.coreplugins;

import processing.core.PApplet;
import timbap.visualizer.api.model.RecordItem;
import timbap.visualizer.api.model.Transformation;
import timbap.visualizer.api.plugin.recorditems.AbstractSelectedRecordItemPlugin;

public class FractionPlayedOverlayPlugin extends AbstractSelectedRecordItemPlugin {

    
    protected void applyRecordItemTrafo(RecordItem pRecordItem, float pScaleFactor) {
        
        Transformation tRecordItemTrafo = pRecordItem.getTransformation();
        
        getContext().getP5Applet().translate(tRecordItemTrafo.getXTranslation(),
                                             tRecordItemTrafo.getYTranslation(),
                                             tRecordItemTrafo.getZTranslation());
        getContext().getP5Applet().scale(tRecordItemTrafo.getScaleFactor() * pScaleFactor);
        getContext().getP5Applet().rotateX(tRecordItemTrafo.getXRotation());
    }
    
    public void drawRecordItem(RecordItem pRecordItem) {
        
        getContext().getP5Applet().pushMatrix();
        applyRecordItemTrafo(pRecordItem, getContext().getCfg().getScreenHeight() / 400f);
        
        getContext().getP5Applet().scale(0.8f);
        getContext().getP5Applet().rotate(-PApplet.HALF_PI);
        getContext().getP5Applet().translate(0,0,2);
        getContext().getP5Applet().fill(0,0,0,150);
        getContext().getP5Applet().arc(0, 0, 100, 100, 0, PApplet.TWO_PI * pRecordItem.getFractionPlayed());
        
        getContext().getP5Applet().popMatrix();
    }
    
    
    

}
